# 给一个列表，用grade来排序
classes = [
    {"name": "n_1", "age": 22, "grade": "A"},
    {"name": "n_2", "age": 21, "grade": "B"},
    {"name": "n_3", "age": 20, "grade": "C"},
    {"name": "n_4", "age": 18, "grade": "A"},
    {"name": "n_5", "age": 19, "grade": "B"},
    {"name": "n_6", "age": 20, "grade": "C"},
    {"name": "n_7", "age": 22, "grade": "A"},
    {"name": "n_8", "age": 21, "grade": "B"},
]

a = classes
a.sort(key=lambda x: x["grade"])
print(a)

# 通过filter语句来筛选grade为A的同学
b = filter(lambda x: True if x["grade"] == "A" else False, classes)
print(list(b))

# 通过map函数将上述同学的age+1
def add(c):
    return c["age"] + 1

d = map(add, classes)
print(list(d))

# 通过递归函数重构斐波那契函数
def my_sub(n):
    if n == 0:
        return 0
    elif n == 1:
        return 1
    else:
        return my_sub(n-1) + my_sub(n-2)

for i in range(1000):
    if my_sub(i) > 100:
        break
    print(my_sub(i), end=",")